package logic

import (
	"context"
	"errors"
	"math/rand"

	"gong/gongrpc/gongrpc"
	"gong/gongrpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type SendSmsLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewSendSmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendSmsLogic {
	return &SendSmsLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *SendSmsLogic) SendSms(in *gongrpc.SendSmsRequest) (*gongrpc.SendSmsResponse, error) {
	// todo: add your logic here and delete this line
	Send := rand.Intn(9000) + 1000

	if Send > 5 {
		return nil, errors.New("短信最多发送五次")
	}

	return &gongrpc.SendSmsResponse{}, nil
}
